package demoMod.moduploader.ui;

import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.backends.lwjgl.LwjglFileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import demoMod.gdxform.enums.GFrameWindowMode;
import demoMod.gdxform.enums.GFrameWindowStyle;
import demoMod.gdxform.helpers.FontHelper;
import demoMod.gdxform.ui.GFrame;
import demoMod.moduploader.fonts.FontKeys;
import demoMod.moduploader.localization.LocalizedStrings;

import java.util.List;

public class AboutWindow extends GFrame {
    private final List<String> strings = LocalizedStrings.getStrings("AboutWindow");
    private final Music bgm = Gdx.audio.newMusic(new LwjglFileHandle("audio/music/Transient.mp3", Files.FileType.Internal));

    public AboutWindow() {
        super(Gdx.graphics.getWidth() / 2.0F - 225.0F, Gdx.graphics.getHeight() / 2.0F - 150.0F, 450, 325, FontHelper.getFont(FontKeys.SIM_HEI_14), GFrameWindowStyle.CLOSE_BUTTON_ONLY, false);
        setWindowMode(GFrameWindowMode.MODAL);
        setTitle(strings.get(0));
        bgm.setLooping(true);
        bgm.setVolume(0.5F);
        bgm.play();
    }

    @Override
    public void render(SpriteBatch sb) {
        super.render(sb);
        FontHelper.renderFontCentered(sb, FontHelper.getFont(FontKeys.SIM_HEI_16_BOLD), "STS Mod Uploader", getX(true) + getWidth() / 2.0F, getY(true) + getHeight() * 0.575F, Color.WHITE);
        FontHelper.renderFontCentered(sb, FontHelper.getFont(FontKeys.SIM_HEI_14), "v1.0.0", getX(true) + getWidth() / 2.0F, getY(true) + getHeight() * 0.5F, Color.WHITE);
        FontHelper.renderFontCentered(sb, FontHelper.getFont(FontKeys.SIM_HEI_12), strings.get(1), getX(true) + getWidth() / 2.0F, getY(true) + getHeight() * 0.425F, Color.WHITE);
        FontHelper.renderFontCentered(sb, FontHelper.getFont(FontKeys.SIM_HEI_12), strings.get(2), getX(true) + getWidth() / 2.0F, getY(true) + getHeight() * 0.35F, Color.WHITE);
        sb.flush();
    }

    @Override
    public void dispose() {
        super.dispose();
        this.bgm.stop();
        this.bgm.dispose();
    }
}
